<?php
/**
 * @brief change_max_hp protocol
 *
 * @param post uid User ID
 * @return money, max_hp
 * @author con100 <con100@playplus.net>
 * @since 05/04/2013
 * @copyright Copyright (c) 2013, PlayPlus
 **/
include 'config.php';
include 'dbconn.php';

$user_id = mysql_real_escape_string($_POST['uid']);

$sql = "select max_hp, money, nation from ebs_member where id='$user_id'";
$res = mysql_query($sql);
$data = mysql_fetch_assoc($res);
//최대HP 증가 비용
$pay_maxup = _getMaxHpPay_($data);

if($data['money'] >= $pay_maxup){
	$data['money']-= $pay_maxup;
	$data['max_hp'] += $_max_hp_up_;
	$sql = "update ebs_member set money='$data[money]', max_hp=' $data[max_hp]' where id='$user_id'";
	$res = mysql_query($sql);
	$result = array("Result"=>TRUE, "money"=>$data['money'], "max_hp"=> $data['max_hp']);
}
else{
	$result = array("Result"=>FALSE);
}
echo json_encode($result);
/*
header('Content-type: text/xml; charset=UTF-8');

$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->setIndentString('  ');
$writer->startDocument('1.0', 'UTF-8');

$writer->startElement('change_max_hp');
	$writer->startElement('result');
	$writer->text($result);
	$writer->endElement();
	if($result == "TRUE"){
		$writer->startElement('money');
		$writer->text($money);
		$writer->endElement();
		$writer->startElement('max_hp');
		$writer->text($max_hp);
		$writer->endElement();
	}
$writer->endElement();

echo($writer->outputMemory());

//국비 조회
$no_nation = $data['nation'];

if($no_nation != 0){
	$sql = "select money from ebs_nation where no='$no_nation'";
	$res = mysql_query($sql);
	$nation = mysql_fetch_assoc($res);
}

//국비에 쌓임
if($no_nation != 0){
	$nation['money'] += $pay_maxup;
	$sql = "update ebs_nation set money='$nation[money]' where no='$no_nation'";
	$res = mysql_query($sql);
}
*/
?>